{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# PLEASE USE `Cell => Run All` ON THIS NOTEBOOK (MENU OPTION ABOVE).\n",
    "\n",
    "# THIS NOTEBOOK WILL TAKE 20-30 MINUTES TO COMPLETE SUCCESSFULLY.\n",
    "\n",
    "# PLEASE BE PATIENT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python Version 3.6.10 |Anaconda, Inc.| (default, Jan  7 2020, 21:14:29) \n",
      "[GCC 7.3.0]\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "print('Python Version %s' % sys.version)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Package                            Version            \n",
      "---------------------------------- -------------------\n",
      "alabaster                          0.7.12             \n",
      "anaconda-client                    1.7.2              \n",
      "anaconda-project                   0.8.3              \n",
      "argh                               0.26.2             \n",
      "asn1crypto                         1.3.0              \n",
      "astroid                            2.4.2              \n",
      "astropy                            4.0                \n",
      "atomicwrites                       1.3.0              \n",
      "attrs                              19.3.0             \n",
      "Automat                            20.2.0             \n",
      "autopep8                           1.4.4              \n",
      "autovizwidget                      0.16.0             \n",
      "awscli                             1.18.169           \n",
      "Babel                              2.8.0              \n",
      "backcall                           0.1.0              \n",
      "backports.shutil-get-terminal-size 1.0.0              \n",
      "bcrypt                             3.2.0              \n",
      "beautifulsoup4                     4.8.2              \n",
      "bitarray                           1.2.1              \n",
      "bkcharts                           0.2                \n",
      "bleach                             3.2.1              \n",
      "bokeh                              1.4.0              \n",
      "boto                               2.49.0             \n",
      "boto3                              1.16.9             \n",
      "botocore                           1.19.9             \n",
      "Bottleneck                         1.3.2              \n",
      "cached-property                    1.5.2              \n",
      "certifi                            2020.6.20          \n",
      "cffi                               1.14.0             \n",
      "chardet                            3.0.4              \n",
      "Click                              7.0                \n",
      "cloudpickle                        1.3.0              \n",
      "clyent                             1.2.2              \n",
      "colorama                           0.4.3              \n",
      "contextlib2                        0.6.0.post1        \n",
      "cryptography                       2.8                \n",
      "cycler                             0.10.0             \n",
      "Cython                             0.29.15            \n",
      "cytoolz                            0.10.1             \n",
      "dask                               2.11.0             \n",
      "decorator                          4.4.1              \n",
      "defusedxml                         0.6.0              \n",
      "diff-match-patch                   20181111           \n",
      "distributed                        2.11.0             \n",
      "distro                             1.5.0              \n",
      "docker                             4.3.1              \n",
      "docker-compose                     1.27.4             \n",
      "dockerpty                          0.4.1              \n",
      "docopt                             0.6.2              \n",
      "docutils                           0.15.2             \n",
      "entrypoints                        0.3                \n",
      "environment-kernels                1.1.1              \n",
      "et-xmlfile                         1.0.1              \n",
      "fastcache                          1.1.0              \n",
      "filelock                           3.0.12             \n",
      "flake8                             3.7.9              \n",
      "Flask                              1.1.1              \n",
      "fsspec                             0.6.2              \n",
      "future                             0.18.2             \n",
      "gevent                             1.4.0              \n",
      "glob2                              0.7                \n",
      "gmpy2                              2.0.8              \n",
      "google-pasta                       0.2.0              \n",
      "greenlet                           0.4.15             \n",
      "h5py                               2.10.0             \n",
      "hdijupyterutils                    0.16.0             \n",
      "HeapDict                           1.0.1              \n",
      "html5lib                           1.0.1              \n",
      "hypothesis                         5.5.4              \n",
      "idna                               2.8                \n",
      "imageio                            2.6.1              \n",
      "imagesize                          1.2.0              \n",
      "importlib-metadata                 1.5.0              \n",
      "intervaltree                       3.0.2              \n",
      "ipykernel                          5.1.4              \n",
      "ipyparallel                        6.3.0              \n",
      "ipython                            7.12.0             \n",
      "ipython-genutils                   0.2.0              \n",
      "ipywidgets                         7.5.1              \n",
      "isort                              4.3.21             \n",
      "itsdangerous                       1.1.0              \n",
      "jdcal                              1.4.1              \n",
      "jedi                               0.14.1             \n",
      "jeepney                            0.4.2              \n",
      "Jinja2                             2.11.1             \n",
      "jmespath                           0.10.0             \n",
      "joblib                             0.14.1             \n",
      "json5                              0.9.1              \n",
      "jsonschema                         3.2.0              \n",
      "jupyter                            1.0.0              \n",
      "jupyter-client                     5.3.4              \n",
      "jupyter-console                    6.1.0              \n",
      "jupyter-core                       4.6.1              \n",
      "jupyterlab                         1.2.6              \n",
      "jupyterlab-server                  1.0.6              \n",
      "keyring                            21.1.0             \n",
      "kiwisolver                         1.1.0              \n",
      "lazy-object-proxy                  1.4.3              \n",
      "libarchive-c                       2.8                \n",
      "lief                               0.9.0              \n",
      "llvmlite                           0.31.0             \n",
      "locket                             0.2.0              \n",
      "lxml                               4.6.1              \n",
      "MarkupSafe                         1.1.1              \n",
      "matplotlib                         3.1.3              \n",
      "mccabe                             0.6.1              \n",
      "mistune                            0.8.4              \n",
      "mkl-fft                            1.0.15             \n",
      "mkl-random                         1.1.0              \n",
      "mkl-service                        2.3.0              \n",
      "mock                               4.0.1              \n",
      "more-itertools                     8.2.0              \n",
      "mpmath                             1.1.0              \n",
      "msgpack                            0.6.1              \n",
      "multipledispatch                   0.6.0              \n",
      "nb-conda                           2.2.1              \n",
      "nb-conda-kernels                   2.2.4              \n",
      "nbconvert                          5.6.1              \n",
      "nbformat                           5.0.4              \n",
      "networkx                           2.4                \n",
      "nltk                               3.4.5              \n",
      "nose                               1.3.7              \n",
      "notebook                           6.0.3              \n",
      "numba                              0.48.0             \n",
      "numexpr                            2.7.1              \n",
      "numpy                              1.18.1             \n",
      "numpydoc                           0.9.2              \n",
      "nvidia-ml-py                       10.418.84          \n",
      "olefile                            0.46               \n",
      "opencv-python                      4.2.0.32           \n",
      "openpyxl                           3.0.3              \n",
      "packaging                          20.1               \n",
      "pandas                             1.0.1              \n",
      "pandocfilters                      1.4.2              \n",
      "paramiko                           2.7.2              \n",
      "parso                              0.5.2              \n",
      "partd                              1.1.0              \n",
      "path                               13.1.0             \n",
      "pathlib2                           2.3.5              \n",
      "pathtools                          0.1.2              \n",
      "patsy                              0.5.1              \n",
      "pep8                               1.7.1              \n",
      "pexpect                            4.8.0              \n",
      "pickleshare                        0.7.5              \n",
      "Pillow                             7.2.0              \n",
      "pip                                20.0.2             \n",
      "pkginfo                            1.5.0.1            \n",
      "plotly                             4.12.0             \n",
      "pluggy                             0.13.1             \n",
      "ply                                3.11               \n",
      "prometheus-client                  0.7.1              \n",
      "prompt-toolkit                     3.0.3              \n",
      "protobuf                           3.11.4             \n",
      "protobuf3-to-dict                  0.1.5              \n",
      "psutil                             5.6.7              \n",
      "psycopg2                           2.7.5              \n",
      "PTable                             0.9.2              \n",
      "ptyprocess                         0.6.0              \n",
      "py                                 1.8.1              \n",
      "py4j                               0.10.7             \n",
      "pyasn1                             0.4.8              \n",
      "pycodestyle                        2.5.0              \n",
      "pycosat                            0.6.3              \n",
      "pycparser                          2.19               \n",
      "pycrypto                           2.6.1              \n",
      "pycurl                             7.43.0.5           \n",
      "pydocstyle                         4.0.1              \n",
      "pyflakes                           2.1.1              \n",
      "pygal                              2.4.0              \n",
      "Pygments                           2.5.2              \n",
      "pykerberos                         1.2.1              \n",
      "pylint                             2.5.3              \n",
      "PyNaCl                             1.4.0              \n",
      "pyodbc                             4.0.0-unsupported  \n",
      "pyOpenSSL                          19.1.0             \n",
      "pyparsing                          2.4.6              \n",
      "pyrsistent                         0.15.7             \n",
      "PySocks                            1.7.1              \n",
      "pyspark                            2.3.4              \n",
      "pytest                             5.3.5              \n",
      "pytest-arraydiff                   0.3                \n",
      "pytest-astropy                     0.8.0              \n",
      "pytest-astropy-header              0.1.2              \n",
      "pytest-doctestplus                 0.5.0              \n",
      "pytest-openfiles                   0.4.0              \n",
      "pytest-remotedata                  0.3.2              \n",
      "python-dateutil                    2.8.1              \n",
      "python-dotenv                      0.15.0             \n",
      "python-jsonrpc-server              0.3.4              \n",
      "python-language-server             0.31.7             \n",
      "pytz                               2019.3             \n",
      "PyWavelets                         1.1.1              \n",
      "pyxdg                              0.26               \n",
      "PyYAML                             5.3.1              \n",
      "pyzmq                              18.1.1             \n",
      "QDarkStyle                         2.8                \n",
      "QtAwesome                          0.6.1              \n",
      "qtconsole                          4.6.0              \n",
      "QtPy                               1.9.0              \n",
      "requests                           2.22.0             \n",
      "requests-kerberos                  0.12.0             \n",
      "retrying                           1.3.3              \n",
      "rope                               0.16.0             \n",
      "rsa                                4.5                \n",
      "Rtree                              0.9.3              \n",
      "ruamel-yaml                        0.15.87            \n",
      "s3fs                               0.4.2              \n",
      "s3transfer                         0.3.3              \n",
      "sagemaker                          2.16.1             \n",
      "sagemaker-pyspark                  1.4.1              \n",
      "scikit-image                       0.16.2             \n",
      "scikit-learn                       0.22.1             \n",
      "scipy                              1.4.1              \n",
      "seaborn                            0.10.0             \n",
      "SecretStorage                      3.1.2              \n",
      "Send2Trash                         1.5.0              \n",
      "setuptools                         45.2.0.post20200210\n",
      "simplegeneric                      0.8.1              \n",
      "singledispatch                     3.4.0.3            \n",
      "six                                1.14.0             \n",
      "smdebug-rulesconfig                0.1.5              \n",
      "snowballstemmer                    2.0.0              \n",
      "sortedcollections                  1.1.2              \n",
      "sortedcontainers                   2.1.0              \n",
      "soupsieve                          1.9.5              \n",
      "sparkmagic                         0.15.0             \n",
      "Sphinx                             3.0.4              \n",
      "sphinxcontrib-applehelp            1.0.1              \n",
      "sphinxcontrib-devhelp              1.0.1              \n",
      "sphinxcontrib-htmlhelp             1.0.2              \n",
      "sphinxcontrib-jsmath               1.0.1              \n",
      "sphinxcontrib-qthelp               1.0.2              \n",
      "sphinxcontrib-serializinghtml      1.1.3              \n",
      "sphinxcontrib-websupport           1.2.0              \n",
      "spyder                             4.0.1              \n",
      "spyder-kernels                     1.8.1              \n",
      "SQLAlchemy                         1.3.13             \n",
      "statsmodels                        0.11.0             \n",
      "sympy                              1.5.1              \n",
      "tables                             3.6.1              \n",
      "tblib                              1.6.0              \n",
      "terminado                          0.8.3              \n",
      "testpath                           0.4.4              \n",
      "texttable                          1.6.3              \n",
      "toml                               0.10.1             \n",
      "toolz                              0.10.0             \n",
      "tornado                            6.0.3              \n",
      "tqdm                               4.42.1             \n",
      "traitlets                          4.3.3              \n",
      "typed-ast                          1.4.1              \n",
      "ujson                              1.35               \n",
      "unicodecsv                         0.14.1             \n",
      "urllib3                            1.25.10            \n",
      "watchdog                           0.10.2             \n",
      "wcwidth                            0.1.8              \n",
      "webencodings                       0.5.1              \n",
      "websocket-client                   0.57.0             \n",
      "Werkzeug                           1.0.0              \n",
      "wheel                              0.34.2             \n",
      "widgetsnbextension                 3.5.1              \n",
      "wrapt                              1.11.2             \n",
      "wurlitzer                          2.0.0              \n",
      "xlrd                               1.2.0              \n",
      "XlsxWriter                         1.2.7              \n",
      "xlwt                               1.3.0              \n",
      "yapf                               0.28.0             \n",
      "zict                               1.0.0              \n",
      "zipp                               2.2.0              \n",
      "\u001b[33mWARNING: You are using pip version 20.0.2; however, version 20.2.4 is available.\n",
      "You should consider upgrading via the '/home/ec2-user/anaconda3/envs/python3/bin/python -m pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "# packages in environment at /home/ec2-user/anaconda3/envs/python3:\n",
      "#\n",
      "# Name                    Version                   Build  Channel\n",
      "_libgcc_mutex             0.1                        main  \n",
      "alabaster                 0.7.12                   py36_0  \n",
      "anaconda-client           1.7.2                    py36_0  \n",
      "anaconda-project          0.8.4                      py_0  \n",
      "argh                      0.26.2                   py36_0  \n",
      "argparse                  1.4.0                    pypi_0    pypi\n",
      "asn1crypto                1.3.0                    py36_0  \n",
      "astroid                   2.4.2                    pypi_0    pypi\n",
      "astropy                   4.0              py36h7b6447c_0  \n",
      "atomicwrites              1.3.0                    py36_1  \n",
      "attrs                     19.3.0                     py_0  \n",
      "automat                   20.2.0                   pypi_0    pypi\n",
      "autopep8                  1.4.4                      py_0  \n",
      "autovizwidget             0.16.0                   pypi_0    pypi\n",
      "awscli                    1.18.169                 pypi_0    pypi\n",
      "babel                     2.8.0                      py_0  \n",
      "backcall                  0.1.0                    py36_0  \n",
      "backports                 1.0                        py_2  \n",
      "backports.shutil_get_terminal_size 1.0.0                    py36_2  \n",
      "bcrypt                    3.2.0                    pypi_0    pypi\n",
      "beautifulsoup4            4.8.2                    py36_0  \n",
      "bitarray                  1.2.1            py36h7b6447c_0  \n",
      "bkcharts                  0.2                      py36_0  \n",
      "blas                      1.0                         mkl  \n",
      "bleach                    3.2.1                    pypi_0    pypi\n",
      "blosc                     1.16.3               hd408876_0  \n",
      "bokeh                     1.4.0                    py36_0  \n",
      "boto                      2.49.0                   py36_0  \n",
      "boto3                     1.16.9                   pypi_0    pypi\n",
      "botocore                  1.19.9                   pypi_0    pypi\n",
      "bottleneck                1.3.2            py36heb32a55_0  \n",
      "bzip2                     1.0.8                h7b6447c_0  \n",
      "ca-certificates           2020.6.20            hecda079_0    conda-forge\n",
      "cached-property           1.5.2                    pypi_0    pypi\n",
      "cairo                     1.14.12              h8948797_3  \n",
      "certifi                   2020.6.20        py36h9880bd3_2    conda-forge\n",
      "cffi                      1.14.0           py36h2e261b9_0  \n",
      "chardet                   3.0.4                 py36_1003  \n",
      "click                     7.0                      py36_0  \n",
      "cloudpickle               1.3.0                      py_0  \n",
      "clyent                    1.2.2                    py36_1  \n",
      "colorama                  0.4.3                      py_0  \n",
      "contextlib2               0.6.0.post1                py_0  \n",
      "cryptography              2.8              py36h1ba5d50_0  \n",
      "curl                      7.68.0               hbc83047_0  \n",
      "cycler                    0.10.0                   py36_0  \n",
      "cython                    0.29.15          py36he6710b0_0  \n",
      "cytoolz                   0.10.1           py36h7b6447c_0  \n",
      "dask                      2.11.0                     py_0  \n",
      "dask-core                 2.11.0                     py_0  \n",
      "dbus                      1.13.12              h746ee38_0  \n",
      "decorator                 4.4.1                      py_0  \n",
      "defusedxml                0.6.0                      py_0  \n",
      "diff-match-patch          20181111                   py_0  \n",
      "distributed               2.11.0                   py36_0  \n",
      "distro                    1.5.0                    pypi_0    pypi\n",
      "docker                    4.3.1                    pypi_0    pypi\n",
      "docker-compose            1.27.4                   pypi_0    pypi\n",
      "dockerpty                 0.4.1                    pypi_0    pypi\n",
      "docopt                    0.6.2                    pypi_0    pypi\n",
      "docutils                  0.15.2                   pypi_0    pypi\n",
      "entrypoints               0.3                      py36_0  \n",
      "environment-kernels       1.1.1                    pypi_0    pypi\n",
      "et_xmlfile                1.0.1                    py36_0  \n",
      "expat                     2.2.6                he6710b0_0  \n",
      "fastcache                 1.1.0            py36h7b6447c_0  \n",
      "filelock                  3.0.12                     py_0  \n",
      "flake8                    3.7.9                    py36_0  \n",
      "flask                     1.1.1                      py_0  \n",
      "fontconfig                2.13.0               h9420a91_0  \n",
      "freetype                  2.9.1                h8a8886c_1  \n",
      "fribidi                   1.0.5                h7b6447c_0  \n",
      "fsspec                    0.6.2                      py_0  \n",
      "future                    0.18.2                   py36_0  \n",
      "get_terminal_size         1.0.0                haa9412d_0  \n",
      "gevent                    1.4.0            py36h7b6447c_0  \n",
      "glib                      2.63.1               h5a9c865_0  \n",
      "glob2                     0.7                        py_0  \n",
      "gmp                       6.1.2                h6c8ec71_1  \n",
      "gmpy2                     2.0.8            py36h10f8cd9_2  \n",
      "google-pasta              0.2.0                    pypi_0    pypi\n",
      "graphite2                 1.3.13               h23475e2_0  \n",
      "graphviz                  2.40.1               h21bd128_2  \n",
      "greenlet                  0.4.15           py36h7b6447c_0  \n",
      "gst-plugins-base          1.14.0               hbbd80ab_1  \n",
      "gstreamer                 1.14.0               hb453b48_1  \n",
      "h5py                      2.10.0           py36h7918eee_0  \n",
      "harfbuzz                  1.8.8                hffaf4a1_0  \n",
      "hdf5                      1.10.4               hb1b8bf9_0  \n",
      "hdijupyterutils           0.16.0                   pypi_0    pypi\n",
      "heapdict                  1.0.1                      py_0  \n",
      "html5lib                  1.0.1                    py36_0  \n",
      "hypothesis                5.5.4                      py_0  \n",
      "icu                       58.2                 h9c2bf20_1  \n",
      "idna                      2.8                      py36_0  \n",
      "imageio                   2.6.1                    py36_0  \n",
      "imagesize                 1.2.0                      py_0  \n",
      "importlib_metadata        1.5.0                    py36_0  \n",
      "intel-openmp              2020.0                      166  \n",
      "intervaltree              3.0.2                      py_0  \n",
      "ipykernel                 5.1.4            py36h39e3cac_0  \n",
      "ipyparallel               6.3.0                    py36_0  \n",
      "ipython                   7.12.0           py36h5ca1d4c_0  \n",
      "ipython_genutils          0.2.0                    py36_0  \n",
      "ipywidgets                7.5.1                      py_0  \n",
      "isort                     4.3.21                   py36_0  \n",
      "itsdangerous              1.1.0                    py36_0  \n",
      "jbig                      2.1                  hdba287a_0  \n",
      "jdcal                     1.4.1                      py_0  \n",
      "jedi                      0.14.1                   py36_0  \n",
      "jeepney                   0.4.2                      py_0  \n",
      "jinja2                    2.11.1                     py_0  \n",
      "jmespath                  0.10.0                     py_0  \n",
      "joblib                    0.14.1                     py_0  \n",
      "jpeg                      9b                   h024ee3a_2  \n",
      "json5                     0.9.1                      py_0  \n",
      "jsonschema                3.2.0                    py36_0  \n",
      "jupyter                   1.0.0                    py36_7  \n",
      "jupyter_client            5.3.4                    py36_0  \n",
      "jupyter_console           6.1.0                      py_0  \n",
      "jupyter_core              4.6.1                    py36_0  \n",
      "jupyterlab                1.2.6              pyhf63ae98_0  \n",
      "jupyterlab_server         1.0.6                      py_0  \n",
      "keyring                   21.1.0                   py36_0  \n",
      "kiwisolver                1.1.0            py36he6710b0_0  \n",
      "krb5                      1.17.1               h173b8e3_0  \n",
      "lazy-object-proxy         1.4.3            py36h7b6447c_0  \n",
      "ld_impl_linux-64          2.33.1               h53a641e_7  \n",
      "libarchive                3.3.3                h5d8350f_5  \n",
      "libcurl                   7.68.0               h20c2e04_0  \n",
      "libedit                   3.1.20181209         hc058e9b_0  \n",
      "libffi                    3.2.1                hd88cf55_4  \n",
      "libgcc-ng                 9.1.0                hdf63c60_0  \n",
      "libgfortran-ng            7.3.0                hdf63c60_0  \n",
      "liblief                   0.9.0                h7725739_2  \n",
      "libpng                    1.6.37               hbc83047_0  \n",
      "libprotobuf               3.11.4               h8b12597_0    conda-forge\n",
      "libsodium                 1.0.16               h1bed415_0  \n",
      "libspatialindex           1.9.3                he6710b0_0  \n",
      "libssh2                   1.8.2                h1ba5d50_0  \n",
      "libstdcxx-ng              9.1.0                hdf63c60_0  \n",
      "libtiff                   4.1.0                h2733197_0  \n",
      "libtool                   2.4.6                h7b6447c_5  \n",
      "libuuid                   1.0.3                h1bed415_2  \n",
      "libxcb                    1.13                 h1bed415_1  \n",
      "libxml2                   2.9.9                hea5a465_1  \n",
      "libxslt                   1.1.33               h7d1a2b0_0  \n",
      "llvmlite                  0.31.0           py36hd408876_0  \n",
      "locket                    0.2.0                    py36_1  \n",
      "lxml                      4.6.1                    pypi_0    pypi\n",
      "lz4-c                     1.8.1.2              h14c3975_0  \n",
      "lzo                       2.10                 h49e0be7_2  \n",
      "markupsafe                1.1.1            py36h7b6447c_0  \n",
      "matplotlib                3.1.3                    py36_0  \n",
      "matplotlib-base           3.1.3            py36hef1b27d_0  \n",
      "mccabe                    0.6.1                    py36_1  \n",
      "mistune                   0.8.4            py36h7b6447c_0  \n",
      "mkl                       2020.0                      166  \n",
      "mkl-service               2.3.0            py36he904b0f_0  \n",
      "mkl_fft                   1.0.15           py36ha843d7b_0  \n",
      "mkl_random                1.1.0            py36hd6b4f25_0  \n",
      "mock                      4.0.1                      py_0  \n",
      "more-itertools            8.2.0                      py_0  \n",
      "mpc                       1.1.0                h10f8cd9_1  \n",
      "mpfr                      4.0.1                hdf1c602_3  \n",
      "mpmath                    1.1.0                    py36_0  \n",
      "msgpack-python            0.6.1            py36hfd86e86_1  \n",
      "multipledispatch          0.6.0                    py36_0  \n",
      "nb_conda                  2.2.1                    py36_0  \n",
      "nb_conda_kernels          2.2.4                    py36_0  \n",
      "nbconvert                 5.6.1                    py36_0  \n",
      "nbformat                  5.0.4                      py_0  \n",
      "ncurses                   6.2                  he6710b0_0  \n",
      "networkx                  2.4                        py_0  \n",
      "nltk                      3.4.5                    py36_0  \n",
      "nose                      1.3.7                    py36_2  \n",
      "notebook                  6.0.3                    py36_0  \n",
      "numba                     0.48.0           py36h0573a6f_0  \n",
      "numexpr                   2.7.1            py36h423224d_0  \n",
      "numpy                     1.18.1           py36h4f9e942_0  \n",
      "numpy-base                1.18.1           py36hde5b4d6_1  \n",
      "numpydoc                  0.9.2                      py_0  \n",
      "nvidia-ml-py              10.418.84                pypi_0    pypi\n",
      "olefile                   0.46                     py36_0  \n",
      "opencv-python             4.2.0.32                 pypi_0    pypi\n",
      "openpyxl                  3.0.3                      py_0  \n",
      "openssl                   1.1.1h               h516909a_0    conda-forge\n",
      "packaging                 20.1                       py_0  \n",
      "pandas                    1.0.1            py36h0573a6f_0  \n",
      "pandoc                    2.2.3.2                       0  \n",
      "pandocfilters             1.4.2                    py36_1  \n",
      "pango                     1.42.4               h049681c_0  \n",
      "paramiko                  2.7.2                    pypi_0    pypi\n",
      "parso                     0.5.2                      py_0  \n",
      "partd                     1.1.0                      py_0  \n",
      "patchelf                  0.10                 he6710b0_0  \n",
      "path                      13.1.0                   py36_0  \n",
      "path.py                   12.4.0                        0  \n",
      "pathlib2                  2.3.5                    py36_0  \n",
      "pathtools                 0.1.2                      py_1  \n",
      "patsy                     0.5.1                    py36_0  \n",
      "pcre                      8.43                 he6710b0_0  \n",
      "pep8                      1.7.1                    py36_0  \n",
      "pexpect                   4.8.0                    py36_0  \n",
      "pickleshare               0.7.5                    py36_0  \n",
      "pillow                    7.2.0                    pypi_0    pypi\n",
      "pip                       20.0.2                   pypi_0    pypi\n",
      "pixman                    0.38.0               h7b6447c_0  \n",
      "pkginfo                   1.5.0.1                  py36_0  \n",
      "plotly                    4.12.0                   pypi_0    pypi\n",
      "pluggy                    0.13.1                   py36_0  \n",
      "ply                       3.11                     py36_0  \n",
      "prometheus_client         0.7.1                      py_0  \n",
      "prompt_toolkit            3.0.3                      py_0  \n",
      "protobuf                  3.11.4           py36h831f99a_1    conda-forge\n",
      "protobuf3-to-dict         0.1.5                    pypi_0    pypi\n",
      "psutil                    5.6.7            py36h7b6447c_0  \n",
      "psycopg2                  2.7.5                    pypi_0    pypi\n",
      "ptable                    0.9.2                    pypi_0    pypi\n",
      "ptyprocess                0.6.0                    py36_0  \n",
      "py                        1.8.1                      py_0  \n",
      "py-lief                   0.9.0            py36h7725739_2  \n",
      "py4j                      0.10.7                   pypi_0    pypi\n",
      "pyasn1                    0.4.8                    pypi_0    pypi\n",
      "pycodestyle               2.5.0                    py36_0  \n",
      "pycosat                   0.6.3            py36h7b6447c_0  \n",
      "pycparser                 2.19                     py36_0  \n",
      "pycrypto                  2.6.1            py36h14c3975_9  \n",
      "pycurl                    7.43.0.5         py36h1ba5d50_0  \n",
      "pydocstyle                4.0.1                      py_0  \n",
      "pyflakes                  2.1.1                    py36_0  \n",
      "pygal                     2.4.0                    pypi_0    pypi\n",
      "pygments                  2.5.2                      py_0  \n",
      "pykerberos                1.2.1                    pypi_0    pypi\n",
      "pylint                    2.5.3                    pypi_0    pypi\n",
      "pynacl                    1.4.0                    pypi_0    pypi\n",
      "pyodbc                    4.0.30           py36he6710b0_0  \n",
      "pyopenssl                 19.1.0                   py36_0  \n",
      "pyparsing                 2.4.6                      py_0  \n",
      "pyqt                      5.9.2            py36h05f1152_2  \n",
      "pyrsistent                0.15.7           py36h7b6447c_0  \n",
      "pysocks                   1.7.1                    py36_0  \n",
      "pyspark                   2.3.4                    pypi_0    pypi\n",
      "pytables                  3.6.1            py36h71ec239_0  \n",
      "pytest                    5.3.5                    py36_0  \n",
      "pytest-arraydiff          0.3              py36h39e3cac_0  \n",
      "pytest-astropy            0.8.0                      py_0  \n",
      "pytest-astropy-header     0.1.2                      py_0  \n",
      "pytest-doctestplus        0.5.0                      py_0  \n",
      "pytest-openfiles          0.4.0                      py_0  \n",
      "pytest-remotedata         0.3.2                    py36_0  \n",
      "python                    3.6.10               h0371630_0  \n",
      "python-dateutil           2.8.1                      py_0  \n",
      "python-dotenv             0.15.0                   pypi_0    pypi\n",
      "python-jsonrpc-server     0.3.4                      py_0  \n",
      "python-language-server    0.31.7                   py36_0  \n",
      "python-libarchive-c       2.8                     py36_13  \n",
      "python_abi                3.6                     1_cp36m    conda-forge\n",
      "pytz                      2019.3                     py_0  \n",
      "pywavelets                1.1.1            py36h7b6447c_0  \n",
      "pyxdg                     0.26                       py_0  \n",
      "pyyaml                    5.3.1                    pypi_0    pypi\n",
      "pyzmq                     18.1.1           py36he6710b0_0  \n",
      "qdarkstyle                2.8                        py_0  \n",
      "qt                        5.9.7                h5867ecd_1  \n",
      "qtawesome                 0.6.1                      py_0  \n",
      "qtconsole                 4.6.0                      py_1  \n",
      "qtpy                      1.9.0                      py_0  \n",
      "readline                  7.0                  h7b6447c_5  \n",
      "requests                  2.22.0                   py36_1  \n",
      "requests-kerberos         0.12.0                   pypi_0    pypi\n",
      "retrying                  1.3.3                    pypi_0    pypi\n",
      "ripgrep                   11.0.2               he32d670_0  \n",
      "rope                      0.16.0                     py_0  \n",
      "rsa                       4.5                      pypi_0    pypi\n",
      "rtree                     0.9.3                    py36_0  \n",
      "ruamel_yaml               0.15.87          py36h7b6447c_0  \n",
      "s3fs                      0.4.2                      py_0  \n",
      "s3transfer                0.3.3                    pypi_0    pypi\n",
      "sagemaker                 2.16.1                   pypi_0    pypi\n",
      "sagemaker-pyspark         1.4.1                    pypi_0    pypi\n",
      "scikit-image              0.16.2           py36h0573a6f_0  \n",
      "scikit-learn              0.22.1           py36hd81dba3_0  \n",
      "scipy                     1.4.1            py36h0b6359f_0  \n",
      "seaborn                   0.10.0                     py_0  \n",
      "secretstorage             3.1.2                    py36_0  \n",
      "send2trash                1.5.0                    py36_0  \n",
      "setuptools                45.2.0                   py36_0  \n",
      "simplegeneric             0.8.1                    py36_2  \n",
      "singledispatch            3.4.0.3                  py36_0  \n",
      "sip                       4.19.8           py36hf484d3e_0  \n",
      "six                       1.14.0                   py36_0  \n",
      "smdebug-rulesconfig       0.1.5                    pypi_0    pypi\n",
      "snappy                    1.1.7                hbae5bb6_3  \n",
      "snowballstemmer           2.0.0                      py_0  \n",
      "sortedcollections         1.1.2                    py36_0  \n",
      "sortedcontainers          2.1.0                    py36_0  \n",
      "soupsieve                 1.9.5                    py36_0  \n",
      "sparkmagic                0.15.0                   pypi_0    pypi\n",
      "sphinx                    3.0.4                    pypi_0    pypi\n",
      "sphinxcontrib             1.0                      py36_1  \n",
      "sphinxcontrib-applehelp   1.0.1                      py_0  \n",
      "sphinxcontrib-devhelp     1.0.1                      py_0  \n",
      "sphinxcontrib-htmlhelp    1.0.2                      py_0  \n",
      "sphinxcontrib-jsmath      1.0.1                      py_0  \n",
      "sphinxcontrib-qthelp      1.0.2                      py_0  \n",
      "sphinxcontrib-serializinghtml 1.1.3                      py_0  \n",
      "sphinxcontrib-websupport  1.2.0                      py_0  \n",
      "spyder                    4.0.1                    py36_0  \n",
      "spyder-kernels            1.8.1                    py36_0  \n",
      "sqlalchemy                1.3.13           py36h7b6447c_0  \n",
      "sqlite                    3.31.1               h7b6447c_0  \n",
      "statsmodels               0.11.0           py36h7b6447c_0  \n",
      "sympy                     1.5.1                    py36_0  \n",
      "tbb                       2020.0               hfd86e86_0  \n",
      "tblib                     1.6.0                      py_0  \n",
      "terminado                 0.8.3                    py36_0  \n",
      "testpath                  0.4.4                      py_0  \n",
      "texttable                 1.6.3                    pypi_0    pypi\n",
      "tk                        8.6.8                hbc83047_0  \n",
      "toml                      0.10.1                   pypi_0    pypi\n",
      "toolz                     0.10.0                     py_0  \n",
      "tornado                   6.0.3            py36h7b6447c_3  \n",
      "tqdm                      4.42.1                     py_0  \n",
      "traitlets                 4.3.3                    py36_0  \n",
      "typed-ast                 1.4.1            py36h7b6447c_0  \n",
      "ujson                     1.35             py36h14c3975_0  \n",
      "unicodecsv                0.14.1                   py36_0  \n",
      "unixodbc                  2.3.7                h14c3975_0  \n",
      "urllib3                   1.25.10                  pypi_0    pypi\n",
      "watchdog                  0.10.2                   py36_0  \n",
      "wcwidth                   0.1.8                      py_0  \n",
      "webencodings              0.5.1                    py36_1  \n",
      "websocket-client          0.57.0                   pypi_0    pypi\n",
      "werkzeug                  1.0.0                      py_0  \n",
      "wheel                     0.34.2                   py36_0  \n",
      "widgetsnbextension        3.5.1                    py36_0  \n",
      "wrapt                     1.11.2           py36h7b6447c_0  \n",
      "wurlitzer                 2.0.0                    py36_0  \n",
      "xlrd                      1.2.0                    py36_0  \n",
      "xlsxwriter                1.2.7                      py_0  \n",
      "xlwt                      1.3.0                    py36_0  \n",
      "xz                        5.2.4                h14c3975_4  \n",
      "yaml                      0.1.7                had09818_2  \n",
      "yapf                      0.28.0                     py_0  \n",
      "zeromq                    4.3.1                he6710b0_3  \n",
      "zict                      1.0.0                      py_0  \n",
      "zipp                      2.2.0                      py_0  \n",
      "zlib                      1.2.11               h7b6447c_3  \n",
      "zstd                      1.3.7                h0b5b093_0  \n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "conda list"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1. Install the CLI tools\n",
    "\n",
    "_Note:  Make sure the SageMaker role has access to create EKS Cluster._"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting awscli\n",
      "  Downloading awscli-1.18.183-py2.py3-none-any.whl (3.4 MB)\n",
      "Collecting botocore==1.19.23\n",
      "  Downloading botocore-1.19.23-py2.py3-none-any.whl (6.8 MB)\n",
      "Requirement already satisfied, skipping upgrade: PyYAML<5.4,>=3.10; python_version != \"3.4\" in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from awscli) (5.3)\n",
      "Requirement already satisfied, skipping upgrade: docutils<0.16,>=0.10 in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from awscli) (0.15.2)\n",
      "Requirement already satisfied, skipping upgrade: rsa<=4.5.0,>=3.1.2; python_version != \"3.4\" in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from awscli) (4.5)\n",
      "Requirement already satisfied, skipping upgrade: s3transfer<0.4.0,>=0.3.0 in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from awscli) (0.3.3)\n",
      "Requirement already satisfied, skipping upgrade: colorama<0.4.4,>=0.2.5; python_version != \"3.4\" in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from awscli) (0.4.3)\n",
      "Requirement already satisfied, skipping upgrade: urllib3<1.27,>=1.25.4; python_version != \"3.4\" in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from botocore==1.19.23->awscli) (1.25.8)\n",
      "Requirement already satisfied, skipping upgrade: python-dateutil<3.0.0,>=2.1 in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from botocore==1.19.23->awscli) (2.8.1)\n",
      "Requirement already satisfied, skipping upgrade: jmespath<1.0.0,>=0.7.1 in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from botocore==1.19.23->awscli) (0.10.0)\n",
      "Requirement already satisfied, skipping upgrade: pyasn1>=0.1.3 in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from rsa<=4.5.0,>=3.1.2; python_version != \"3.4\"->awscli) (0.4.8)\n",
      "Requirement already satisfied, skipping upgrade: six>=1.5 in /home/ec2-user/anaconda3/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore==1.19.23->awscli) (1.14.0)\n",
      "Installing collected packages: botocore, awscli\n",
      "Successfully installed awscli-1.18.183 botocore-1.19.23\n",
      "0.32.0\n",
      "Client Version: v1.18.8-eks-7c9bda\n",
      "{\"Version\":\"v0.5.0\",\"Commit\":\"1cfe2a90f68381eacd7b6dcfa2bf689e76eb8b4b\"}\n",
      "Loaded plugins: dkms-build-requires, priorities, update-motd, upgrade-helper,\n",
      "              : versionlock\n",
      "Package jq-1.5-1.2.amzn1.x86_64 already installed and latest version\n",
      "Package gettext-0.18.1.1-9.1.11.amzn1.x86_64 already installed and latest version\n",
      "Nothing to do\n",
      "kubectl in path\n",
      "jq in path\n",
      "envsubst in path\n",
      "Completed\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: You are using pip version 20.0.2; however, version 20.2.4 is available.\n",
      "You should consider upgrading via the '/home/ec2-user/anaconda3/bin/python -m pip install --upgrade pip' command.\n",
      "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n",
      "                                 Dload  Upload   Total   Spent    Left  Speed\n",
      "100 57.2M  100 57.2M    0     0  45.4M      0  0:00:01  0:00:01 --:--:-- 45.4M\n",
      "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n",
      "                                 Dload  Upload   Total   Spent    Left  Speed\n",
      "100 33.6M  100 33.6M    0     0  50.0M      0 --:--:-- --:--:-- --:--:-- 50.0M\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "source ~/.bash_profile\n",
    "\n",
    "pip install awscli --upgrade --user\n",
    "\n",
    "curl --silent --location \"https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz\" | tar xz -C /tmp\n",
    "\n",
    "sudo mv /tmp/eksctl /usr/local/bin\n",
    "\n",
    "eksctl version\n",
    "\n",
    "curl --location -o ./kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.8/2020-09-18/bin/linux/amd64/kubectl\n",
    "#curl --location -o ./kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.15.10/2020-02-22/bin/linux/amd64/kubectl\n",
    "\n",
    "chmod +x ./kubectl\n",
    "\n",
    "sudo mv ./kubectl /usr/local/bin\n",
    "\n",
    "kubectl version --short --client\n",
    "\n",
    "curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.8/2020-09-18/bin/linux/amd64/aws-iam-authenticator\n",
    "#curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.15.10/2020-02-22/bin/linux/amd64/aws-iam-authenticator\n",
    "\n",
    "chmod +x ./aws-iam-authenticator\n",
    "\n",
    "sudo mv aws-iam-authenticator /usr/local/bin\n",
    "\n",
    "aws-iam-authenticator version\n",
    "\n",
    "sudo yum -y install jq gettext\n",
    "\n",
    "for command in kubectl jq envsubst\n",
    "  do\n",
    "    which $command &>/dev/null && echo \"$command in path\" || echo \"$command NOT FOUND\"\n",
    "  done\n",
    "\n",
    "echo \"Completed\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2. Configure the Environment Variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "export AWS_REGION=us-west-2\n",
      "export AWS_CLUSTER_NAME=workshop\n",
      "Completed\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "source ~/.bash_profile\n",
    "\n",
    "export AWS_REGION=$(aws configure get region)\n",
    "echo \"export AWS_REGION=${AWS_REGION}\" | tee -a ~/.bash_profile\n",
    "\n",
    "export AWS_CLUSTER_NAME=workshop\n",
    "echo \"export AWS_CLUSTER_NAME=${AWS_CLUSTER_NAME}\" | tee -a ~/.bash_profile\n",
    "\n",
    "echo \"Completed\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3. Create the EKS Cluster\n",
    "\n",
    "# THIS WILL TAKE 20-30 MINUTES.  PLEASE BE PATIENT!\n",
    "\n",
    "# _If you see `retryable error`s below, this is OK!_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ℹ]  eksctl version 0.32.0\n",
      "[ℹ]  using region us-west-2\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 40.990565ms\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 103.943946ms\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 176.797324ms\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 353.944968ms\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 521.545264ms\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 1.080128224s\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 2.56962464s\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 4.99712896s\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 14.466657536s\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 17.505712128s\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 50.866084864s\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 1m11.549401088s\n",
      "[!]  retryable error (RequestError: send request failed\n",
      "caused by: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)) from ec2metadata/GetToken - will retry after delay of 3m27.526903808s\n",
      "request expired, resigning\n",
      "[ℹ]  subnets for us-west-2a - public:192.168.0.0/19 private:192.168.64.0/19\n",
      "[ℹ]  subnets for us-west-2b - public:192.168.32.0/19 private:192.168.96.0/19\n",
      "[ℹ]  nodegroup \"ng-9706f7a9\" will use \"ami-0b8645c094f80dd52\" [AmazonLinux2/1.18]\n",
      "[ℹ]  using Kubernetes version 1.18\n",
      "[ℹ]  creating EKS cluster \"workshop\" in \"us-west-2\" region with un-managed nodes\n",
      "[ℹ]  will create 2 separate CloudFormation stacks for cluster itself and the initial nodegroup\n",
      "[ℹ]  if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=us-west-2 --cluster=workshop'\n",
      "[ℹ]  CloudWatch logging will not be enabled for cluster \"workshop\" in \"us-west-2\"\n",
      "[ℹ]  you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=us-west-2 --cluster=workshop'\n",
      "[ℹ]  Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster \"workshop\" in \"us-west-2\"\n",
      "[ℹ]  2 sequential tasks: { create cluster control plane \"workshop\", 2 sequential sub-tasks: { no tasks, create nodegroup \"ng-9706f7a9\" } }\n",
      "[ℹ]  building cluster stack \"eksctl-workshop-cluster\"\n",
      "[ℹ]  deploying stack \"eksctl-workshop-cluster\"\n",
      "[ℹ]  building nodegroup stack \"eksctl-workshop-nodegroup-ng-9706f7a9\"\n",
      "[ℹ]  --nodes-min=4 was set automatically for nodegroup ng-9706f7a9\n",
      "[ℹ]  --nodes-max=4 was set automatically for nodegroup ng-9706f7a9\n",
      "[ℹ]  deploying stack \"eksctl-workshop-nodegroup-ng-9706f7a9\"\n",
      "[ℹ]  waiting for the control plane availability...\n",
      "[✔]  saved kubeconfig as \"/home/ec2-user/.kube/config\"\n",
      "[ℹ]  no tasks\n",
      "[✔]  all EKS cluster resources for \"workshop\" have been created\n",
      "[ℹ]  adding identity \"arn:aws:iam::231218423789:role/eksctl-workshop-nodegroup-ng-9706-NodeInstanceRole-XVPKFVUBE1J2\" to auth ConfigMap\n",
      "[ℹ]  nodegroup \"ng-9706f7a9\" has 0 node(s)\n",
      "[ℹ]  waiting for at least 4 node(s) to become ready in \"ng-9706f7a9\"\n",
      "[ℹ]  nodegroup \"ng-9706f7a9\" has 4 node(s)\n",
      "[ℹ]  node \"ip-192-168-18-117.us-west-2.compute.internal\" is ready\n",
      "[ℹ]  node \"ip-192-168-30-41.us-west-2.compute.internal\" is ready\n",
      "[ℹ]  node \"ip-192-168-48-83.us-west-2.compute.internal\" is ready\n",
      "[ℹ]  node \"ip-192-168-50-254.us-west-2.compute.internal\" is ready\n",
      "[ℹ]  kubectl command should work with \"/home/ec2-user/.kube/config\", try 'kubectl get nodes'\n",
      "[✔]  EKS cluster \"workshop\" in \"us-west-2\" region is ready\n",
      "export AWS_CLUSTER_STATUS=ACTIVE\n",
      "Cluster status:  ACTIVE\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "An error occurred (ResourceNotFoundException) when calling the DescribeCluster operation: No cluster found for name: workshop.\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "###############################\n",
    "#\n",
    "# ONLY RUN THIS CELL ONE TIME!!\n",
    "#\n",
    "###############################\n",
    "\n",
    "source ~/.bash_profile\n",
    "\n",
    "export AWS_CLUSTER_STATUS=$(aws eks describe-cluster --name ${AWS_CLUSTER_NAME} --region ${AWS_REGION} --query \"cluster.status\" --output text)\n",
    "\n",
    "if [ -n \"$AWS_CLUSTER_STATUS\" ]; then\n",
    "    if [ $AWS_CLUSTER_STATUS == \"ACTIVE\" ]; then\n",
    "        echo \"Cluster status:  $AWS_CLUSTER_STATUS.\"\n",
    "    else\n",
    "        echo \"Cluster status:  $AWS_CLUSTER_STATUS.  Please wait for status:  ACTIVE\"\n",
    "        exit\n",
    "    fi\n",
    "else\n",
    "    # THIS WILL TAKE 20-30 MINUTES.  PLEASE BE PATIENT. \n",
    "    eksctl create cluster \\\n",
    "      --name ${AWS_CLUSTER_NAME} \\\n",
    "      --version 1.18 \\\n",
    "      --nodes 4 \\\n",
    "      --node-type c5.xlarge \\\n",
    "      --node-volume-size 100 \\\n",
    "      --region=${AWS_REGION} \\\n",
    "      --zones=${AWS_REGION}a,${AWS_REGION}b \\\n",
    "      --alb-ingress-access\n",
    "      \n",
    "    export AWS_CLUSTER_STATUS=$(aws eks describe-cluster --name ${AWS_CLUSTER_NAME} --region ${AWS_REGION} --query \"cluster.status\" --output text)\n",
    "    echo \"export AWS_CLUSTER_STATUS=${AWS_CLUSTER_STATUS}\" | tee -a ~/.bash_profile\n",
    "    echo \"Cluster status:  $AWS_CLUSTER_STATUS\"\n",
    "fi"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# _Your output will look like this..._\n",
    "\n",
    "![](../../../img/verify_eks.png)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# _If you see `retryable error`s  ^^ above ^^, this is OK!_\n",
    "\n",
    "# AFTER 20-30 MINUTES, YOUR CLUSTER WILL BE CREATED."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cluster status:  ACTIVE.  Please continue.\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "source ~/.bash_profile\n",
    "\n",
    "export AWS_CLUSTER_STATUS=$(aws eks describe-cluster --name ${AWS_CLUSTER_NAME} --region ${AWS_REGION} --query \"cluster.status\" --output text)\n",
    "\n",
    "if [ -n \"$AWS_CLUSTER_STATUS\" ]; then\n",
    "    if [ $AWS_CLUSTER_STATUS == \"ACTIVE\" ]; then\n",
    "        echo \"Cluster status:  $AWS_CLUSTER_STATUS.  Please continue.\"\n",
    "    else\n",
    "        echo \"Cluster status:  $AWS_CLUSTER_STATUS.  Please wait for status:  ACTIVE\"\n",
    "        exit\n",
    "    fi\n",
    "fi"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda_python3",
   "language": "python",
   "name": "conda_python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
